﻿<%@ Page Language="VB"  %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
        
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

        '	Authorization level 3 needed for this function
        If Session("userLevel") < 3 Then
            Response.Redirect("/timereport/menu.aspx?msgtype=E&msgno=" & ConfigurationSettings.AppSettings("MSGNO_AUTHORIZATION_FAILED"))
        End If
    
        If (Not IsPostBack) Then
            If Len(Request.QueryString("Projectcode")) > 0 Then
                SchedaProgettoForm.ChangeMode(FormViewMode.Edit)
                SchedaProgettoForm.DefaultMode = FormViewMode.Edit
            End If
        End If
        
    End Sub    

    Sub ValidaCliente_ServerValidate(ByVal sender As Object, ByVal args As ServerValidateEventArgs)

        args.IsValid = False
        
        '   verifica che il codice cliente non sia già stato creato
        Dim connStr As String
        Dim query As String
        Dim conn As SqlConnection
        Dim Adapter As SqlDataAdapter
        Dim ds As DataSet
        
        connStr = ConfigurationManager.ConnectionStrings("MSSql12155ConnectionString").ConnectionString
        conn = New SqlConnection(connStr)
 
        query = "SELECT CodiceCliente FROM Customers  WHERE CodiceCliente='" & args.Value & "'"
 
        Adapter = New SqlDataAdapter(query, conn)
        
        ds = New DataSet()
        Adapter.Fill(ds)
        
        If ds.Tables(0).Rows.Count = 0 Then
            args.IsValid = True
        Else
            args.IsValid = False
        End If

    End Sub
    
    Protected Sub SchedaProgettoForm_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs)
        Response.Redirect("projects_lookup_list.aspx")
    End Sub

    Protected Sub SchedaProgettoForm_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs)                
        Response.Redirect("projects_lookup_list.aspx?messaggio=yes")
    End Sub

    Protected Sub SchedaProgettoForm_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewModeEventArgs)
        If (e.CancelingEdit = True) Then
            Response.Redirect("projects_lookup_list.aspx")
        End If
    End Sub
    
    Sub ValidaProgetto_ServerValidate(ByVal sender As Object, ByVal args As ServerValidateEventArgs)

        Dim c As Object = New ValidationClass
        ' true se non esiste già il record
        args.IsValid = not c.CheckExistence("ProjectCode", args.Value, "Projects")

    End Sub
    
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Protected Sub DropDownList3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Crea Cliente</title>
    <link href="/timereport/include/commoncss.aspx" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            height: 24px;
        }
    </style>
</head>
<script language=JavaScript src= "/timereport/include/menu/menu_array.js" type=text/javascript></script>
<script language=JavaScript src= "/timereport/include/menu/mmenu.js" type=text/javascript></script>  

<body>
<table width="760" border="0"> 
 <tr> 
    <td height="30" class="BarraTop" align="right">Utente: <%= session("UserName") %> 
    </td>
  </tr>
</table> 
    <form id="form1" runat="server">
        <asp:FormView ID="SchedaProgettoForm" runat="server" DataKeyNames="Projects_Id" 
            DataSourceID="projects" OnItemUpdated="SchedaProgettoForm_ItemUpdated" 
            OnItemInserted="SchedaProgettoForm_ItemInserted" CssClass="DetailsView" 
            OnModeChanging="SchedaProgettoForm_ModeChanging" DefaultMode="Insert">
            <EditItemTemplate>
                <table BorderStyle="Solid" BorderWidth="1px">
                    <tr>
                        <th colspan="2">
                            Scheda Progetto</th>
                    </tr>
                    <tr>
                        <td>
                        Codice progetto:</td>
                        <td>
                            <asp:TextBox ID="ProjectCodeTextBox" runat="server" 
                                Text='<%# Bind("ProjectCode") %>' Enabled="False" Columns="10" 
                                MaxLength="10" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Nome progetto (*):</td>
                        <td>
                            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' 
                                Columns="30" MaxLength="50" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="(*)" ControlToValidate="NameTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Codice Cliente</td>
                        <td>
                            <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="cliente" 
                                DataTextField="Nome1" DataValueField="CodiceCliente"  AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("CodiceCliente") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="cliente" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                
                                SelectCommand="SELECT [Nome1], [CodiceCliente] FROM [Customers] ORDER BY [Nome1]">
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Manager</td>
                        <td>
                            <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="manager" 
                                DataTextField="Name" DataValueField="Persons_id" AppendDataBoundItems="True"
                                SelectedValue='<%# Bind("ClientManager_id") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>                             
                            <asp:SqlDataSource ID="manager" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT [Persons_id], [Name] FROM [Persons] ORDER BY [Name]">
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Tipo progetto(*)</td>
                        <td>
                            <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="tipoprogetto" 
                                DataTextField="Name" DataValueField="ProjectType_Id" AppendDataBoundItems="True"
                                SelectedValue='<%# Bind("ProjectType_Id") %>' 
                                onselectedindexchanged="DropDownList3_SelectedIndexChanged" Width="160px">
                                 <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList3" Display="Dynamic"></asp:RequiredFieldValidator> 
                            <asp:SqlDataSource ID="tipoprogetto" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [ProjectType]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Canale (*)</td>
                        <td>
                            <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="canale" 
                                DataTextField="Name" DataValueField="Channels_Id"  AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("Channels_Id") %>' 
                                onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList1" Display="Dynamic"></asp:RequiredFieldValidator> 
                            <asp:SqlDataSource ID="canale" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [Channels]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Società</td>
                        <td>
                            <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="societa" 
                                DataTextField="Name" DataValueField="Company_id" AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("Company_id") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="societa" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [Company] ORDER BY [Name]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Attivo</td>
                        <td>
                            <asp:CheckBox ID="ActiveCheckBox" runat="server" 
                    Checked='<%# Bind("Active") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            Gestione&nbsp;Attività</td>
                        <td class="style1">
                            <asp:CheckBox ID="ActivityOn" runat="server"   
                                Checked='<%# bind("ActivityOn") %>' Enabled="False" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Infrastrutturale</td>
                        <td>
                            <asp:CheckBox ID="Always_availableCheckBox" runat="server" 
                                Checked='<%# Bind("Always_available") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th colspan="2" >
                            Economics</th>
                    </tr>
                    <tr>
                        <td>
                            Tipo Contratto</td>
                        <td>
                            <asp:DropDownList ID="DropDownList7" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="TipoContratto" DataTextField="Descrizione" 
                                DataValueField="TipoContratto_id" 
                                SelectedValue='<%# Bind("TipoContratto") %>'>
                            <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            
                            <asp:SqlDataSource ID="TipoContratto" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                
                                SelectCommand="SELECT [Descrizione], [TipoContratto_id] FROM [TipoContratto]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Revenue</td>
                        <td>
                            <asp:TextBox ID="ImportoRevenueTextBox" runat="server" 
                                Text='<%# Bind("ImportoRevenue") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Spese</td>
                        <td>
                            <asp:TextBox ID="ImportoSpeseTextBox" runat="server" 
                                Text='<%# Bind("ImportoSpese") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Spese a Forfait</td>
                        <td>
                            <asp:CheckBox ID="SpeseForfaitCheckBox" runat="server" 
                                Checked='<%# Bind("SpeseForfait") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Spese a Forfait</td>
                        <td>
                            <asp:TextBox ID="ImportoSpeseForfaitTextBox" runat="server" 
                                Text='<%# Bind("ImportoSpeseForfait") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th colspan="2" >
                            Dati di fatturazione</th>
                    </tr>
                    <tr>
                        <td>
                            Piano di fatturazione</td>
                        <td>
                            <asp:TextBox ID="PianoFatturazioneTextBox" runat="server" 
                                Text='<%# Bind("PianoFatturazione") %>' Columns="22" Rows="5" 
                                TextMode="MultiLine" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Metodo di pagamento</td>
                        <td>
                            <asp:DropDownList ID="DropDownList8" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="MetodoPagamento" DataTextField="Descrizione" 
                                DataValueField="MetodoPagamento" SelectedValue='<%# Bind("MetodoPagamento") %>'>
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="MetodoPagamento" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [MetodoPagamento]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Termini di pagamento</td>
                        <td>
                            <asp:DropDownList ID="DropDownList9" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="TerminiPagamento" DataTextField="Descrizione" 
                                DataValueField="TerminiPagamento" 
                                SelectedValue='<%# Bind("TerminiPagamento") %>'>
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="TerminiPagamento" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [TerminiPagamento]"></asp:SqlDataSource>
                        </td>
                    </tr>
                </table>
                <table class="DetailsViewNote" width="300px">
                    <tr>
                        <th colspan="2" >
                            Actuals</th>
                    </tr>
                    <tr>
                        <td>
                            Revenue Fatturate</td>
                        <td>
                            <asp:TextBox ID="RevenueFatturateTextBox" runat="server" 
                                Text='<%# Bind("RevenueFatturate") %>' />
                        </td>
                        <tr>
                            <td>
                                  Spese Fatturate</td>
                            <td>
                                <asp:TextBox ID="SpeseFatturateTextBox" runat="server" 
                                      Text='<%# Bind("SpeseFatturate") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                  Incassato</td>
                            <td>
                                <asp:TextBox ID="IncassatoTextBox" runat="server" 
                                      Text='<%# Bind("Incassato") %>' />
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                  Note</td></th>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                <asp:TextBox ID="TextBox22" runat="server" Columns="30" Rows="20" 
                                      Text='<%# Bind("Note") %>' TextMode="MultiLine" />
                            </td>
                        </tr>
                </table>
                <br />
                <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" CssClass="FormButton" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" 
                    CssClass="FormButton" />
            </EditItemTemplate>
            <InsertItemTemplate>
                <table BorderStyle="Solid" BorderWidth="1px">
                    <tr>
                        <th colspan="2">
                            Scheda Progetto</th>
                    </tr>
                    <tr>
                        <td>
                        Codice progetto:</td>
                        <td>
                            <asp:TextBox ID="ProjectCodeTextBox" runat="server" 
                                Text='<%# Bind("ProjectCode") %>' Columns="10" MaxLength="10" />
                            <asp:CustomValidator ID="ValidaProgetto" runat="server" Display="Dynamic" ErrorMessage="Codice progetto già esistente" OnServerValidate="ValidaProgetto_ServerValidate" ControlToValidate="ProjectCodeTextBox"></asp:CustomValidator>   
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                ControlToValidate="ProjectCodeTextBox" Display="Dynamic" 
                                ErrorMessage="(*)"></asp:RequiredFieldValidator>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            Nome progetto:</td>
                        <td>
                            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' 
                                Columns="30" MaxLength="50" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="(*)" ControlToValidate="NameTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Codice Cliente</td>
                        <td>
                            <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="cliente" 
                                DataTextField="Nome1" DataValueField="CodiceCliente"  AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("CodiceCliente") %>' Width="160px" >
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="cliente" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                
                                SelectCommand="SELECT [Nome1], [CodiceCliente] FROM [Customers] ORDER BY [Nome1]">
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Manager</td>
                        <td>
                            <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="manager" 
                                DataTextField="Name" DataValueField="Persons_id" AppendDataBoundItems="True"
                                SelectedValue='<%# Bind("ClientManager_id") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList> 
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                ControlToValidate="DropDownList5" Display="Dynamic" ErrorMessage="(*)"></asp:RequiredFieldValidator>
                            <asp:SqlDataSource ID="manager" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT [Persons_id], [Name] FROM [Persons] ORDER BY [Name]">
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Tipo progetto</td>
                        <td>
                            <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="tipoprogetto" 
                                DataTextField="Name" DataValueField="ProjectType_Id" AppendDataBoundItems="True"
                                SelectedValue='<%# Bind("ProjectType_Id") %>' Width="160px">
                                 <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList3" Display="Dynamic"></asp:RequiredFieldValidator> 
                            <asp:SqlDataSource ID="tipoprogetto" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [ProjectType]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Canale</td>
                        <td>
                            <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="canale" 
                                DataTextField="Name" DataValueField="Channels_Id"  AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("Channels_Id") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="(*)" ControlToValidate="DropDownList1" Display="Dynamic"></asp:RequiredFieldValidator>
                            <asp:SqlDataSource ID="canale" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [Channels]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Società</td>
                        <td>
                            <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="societa" 
                                DataTextField="Name" DataValueField="Company_id" AppendDataBoundItems="True" 
                                SelectedValue='<%# Bind("Company_id") %>' Width="160px">
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="societa" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [Company] ORDER BY [Name]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Attivo</td>
                        <td>
                            <asp:CheckBox ID="ActiveCheckBox" runat="server" 
                    Checked='<%# Bind("Active") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            Gestione&nbsp;Attività</td>
                        <td class="style1">
                            <asp:CheckBox ID="ActivityOn" runat="server" 
                                Checked='<%# bind("ActivityOn") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            Infrastrutturale</td>
                        <td class="style1">
                            <asp:CheckBox ID="Always_availableCheckBox" runat="server" 
                                Checked='<%# Bind("Always_available") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th colspan="2" >
                            Economics</th>
                    </tr>
                    <tr>
                        <td>
                            Tipo Contratto</td>
                        <td>
                            <asp:DropDownList ID="DropDownList6" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="TipoContratto" DataTextField="Descrizione" 
                                DataValueField="TipoContratto_id" SelectedValue='<%# Bind("TipoContratto") %>'>
                            <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>                            
                            <asp:SqlDataSource ID="TipoContratto" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [TipoContratto]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Revenue</td>
                        <td>
                            <asp:TextBox ID="ImportoRevenueTextBox" runat="server" 
                                Text='<%# Bind("ImportoRevenue") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Spese</td>
                        <td>
                            <asp:TextBox ID="ImportoSpeseTextBox" runat="server" 
                                Text='<%# Bind("ImportoSpese") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Spese a Forfait</td>
                        <td>
                            <asp:CheckBox ID="SpeseForfaitCheckBox" runat="server" 
                                Checked='<%# Bind("SpeseForfait") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Importo Spese a Forfait</td>
                        <td>
                            <asp:TextBox ID="ImportoSpeseForfaitTextBox" runat="server" 
                                Text='<%# Bind("ImportoSpeseForfait") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th colspan="2" >
                            Dati di fatturazione</th>
                    </tr>
                    <tr>
                        <td>
                            Piano di fatturazione</td>
                        <td>
                            <asp:TextBox ID="PianoFatturazioneTextBox" runat="server" 
                                Text='<%# Bind("PianoFatturazione") %>' Columns="22" Rows="5" 
                                TextMode="MultiLine" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Metodo di pagamento</td>
                        <td>
                            <asp:DropDownList ID="DropDownList8" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="MetodoPagamento" DataTextField="Descrizione" 
                                DataValueField="MetodoPagamento" SelectedValue='<%# Bind("MetodoPagamento") %>'>
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="MetodoPagamento" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [MetodoPagamento]"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Termini di pagamento</td>
                        <td>
                            <asp:DropDownList ID="DropDownList9" runat="server" AppendDataBoundItems="True" 
                                DataSourceID="TerminiPagamento" DataTextField="Descrizione" 
                                DataValueField="TerminiPagamento" 
                                SelectedValue='<%# Bind("TerminiPagamento") %>'>
                                <asp:ListItem  Value="" Text="Selezionare un valore"/>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="TerminiPagamento" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
                                SelectCommand="SELECT * FROM [TerminiPagamento]"></asp:SqlDataSource>
                        </td>
                    </tr>
                </table>
                <table class="DetailsViewNote" width="300px">
                    <tr>
                        <th colspan="2" >
                            Actuals</th>
                    </tr>
                    <tr>
                        <td>
                            Revenue Fatturate</td>
                        <td>
                            <asp:TextBox ID="RevenueFatturateTextBox" runat="server" 
                                Text='<%# Bind("RevenueFatturate") %>' />
                        </td>
                        <tr>
                            <td>
                                  Spese Fatturate</td>
                            <td>
                                <asp:TextBox ID="SpeseFatturateTextBox" runat="server" 
                                      Text='<%# Bind("SpeseFatturate") %>' />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                  Incassato</td>
                            <td>
                                <asp:TextBox ID="IncassatoTextBox" runat="server" 
                                      Text='<%# Bind("Incassato") %>' />
                            </td>
                        </tr>
                        <tr>
                            <th colspan="2">
                                  Note</td></th>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                <asp:TextBox ID="TextBox22" runat="server" Columns="30" Rows="20" 
                                      Text='<%# Bind("Note") %>' TextMode="MultiLine" />
                            </td>
                        </tr>
                </table>
                <br />
                <asp:Button ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" CssClass="FormButton" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" 
                    CssClass="FormButton" />
            </InsertItemTemplate>
            <ItemTemplate>
                Projects_Id:
                <asp:Label ID="Projects_IdLabel" runat="server" 
                    Text='<%# Eval("Projects_Id") %>' />
                <br />
                ProjectCode:
                <asp:Label ID="ProjectCodeLabel" runat="server" 
                    Text='<%# Bind("ProjectCode") %>' />
                <br />
                Name:
                <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                ProjectType_Id:
                <asp:Label ID="ProjectType_IdLabel" runat="server" 
                    Text='<%# Bind("ProjectType_Id") %>' />
                <br />
                Channels_Id:
                <asp:Label ID="Channels_IdLabel" runat="server" 
                    Text='<%# Bind("Channels_Id") %>' />
                <br />
                Company_id:
                <asp:Label ID="Company_idLabel" runat="server" 
                    Text='<%# Bind("Company_id") %>' />
                <br />
                Active:
                <asp:CheckBox ID="ActiveCheckBox" runat="server" 
                    Checked='<%# Bind("Active") %>' Enabled="false" />
                <br />
                Always_available:
                <asp:CheckBox ID="Always_availableCheckBox" runat="server" 
                    Checked='<%# Bind("Always_available") %>' Enabled="false" />
                <br />
                ClientManager_id:
                <asp:Label ID="ClientManager_idLabel" runat="server" 
                    Text='<%# Bind("ClientManager_id") %>' />
                <br />
                TipoContratto:
                <asp:Label ID="TipoContrattoLabel" runat="server" 
                    Text='<%# Bind("TipoContratto") %>' />
                <br />
                ImportoRevenue:
                <asp:Label ID="ImportoRevenueLabel" runat="server" 
                    Text='<%# Bind("ImportoRevenue") %>' />
                <br />
                ImportoSpese:
                <asp:Label ID="ImportoSpeseLabel" runat="server" 
                    Text='<%# Bind("ImportoSpese") %>' />
                <br />
                SpeseForfait:
                <asp:CheckBox ID="SpeseForfaitCheckBox" runat="server" 
                    Checked='<%# Bind("SpeseForfait") %>' Enabled="false" />
                <br />
                ImportoSpeseForfait:
                <asp:Label ID="ImportoSpeseForfaitLabel" runat="server" 
                    Text='<%# Bind("ImportoSpeseForfait") %>' />
                <br />
                RevenueFatturate:
                <asp:Label ID="RevenueFatturateLabel" runat="server" 
                    Text='<%# Bind("RevenueFatturate") %>' />
                <br />
                SpeseFatturate:
                <asp:Label ID="SpeseFatturateLabel" runat="server" 
                    Text='<%# Bind("SpeseFatturate") %>' />
                <br />
                Incassato:
                <asp:Label ID="IncassatoLabel" runat="server" Text='<%# Bind("Incassato") %>' />
                <br />
                PianoFatturazione:
                <asp:Label ID="PianoFatturazioneLabel" runat="server" 
                    Text='<%# Bind("PianoFatturazione") %>' />
                <br />
                MetodoPagamento:
                <asp:Label ID="MetodoPagamentoLabel" runat="server" 
                    Text='<%# Bind("MetodoPagamento") %>' />
                <br />
                TerminiPagamento:
                <asp:Label ID="TerminiPagamentoLabel" runat="server" 
                    Text='<%# Bind("TerminiPagamento") %>' />
                <br />
                CodiceCliente:
                <asp:Label ID="CodiceClienteLabel" runat="server" 
                    Text='<%# Bind("CodiceCliente") %>' />
                <br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                    CommandName="Edit" Text="Edit" />
                &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                    CommandName="Delete" Text="Delete" />
                &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                    CommandName="New" Text="New" />
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="projects" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>" 
            DeleteCommand="DELETE FROM [Projects] WHERE [Projects_Id] = @Projects_Id" 
            InsertCommand="INSERT INTO Projects(ProjectCode, Name, ProjectType_Id, Channels_Id, Company_id, Active, Always_available, ClientManager_id, TipoContratto, ImportoRevenue, ImportoSpese, SpeseForfait, ImportoSpeseForfait, RevenueFatturate, SpeseFatturate, Incassato, PianoFatturazione, MetodoPagamento, TerminiPagamento, CodiceCliente, Note, ActivityOn) VALUES (@ProjectCode, @Name, @ProjectType_Id, @Channels_Id, @Company_id, @Active, @Always_available, @ClientManager_id, @TipoContratto, @ImportoRevenue, @ImportoSpese, @SpeseForfait, @ImportoSpeseForfait, @RevenueFatturate, @SpeseFatturate, @Incassato, @PianoFatturazione, @MetodoPagamento, @TerminiPagamento, @CodiceCliente, @Note, @ActivityOn)" 
            SelectCommand="SELECT * FROM [Projects] WHERE ([ProjectCode] = @ProjectCode)" 
            
            UpdateCommand="UPDATE Projects SET ProjectCode = @ProjectCode, Name = @Name, ProjectType_Id = @ProjectType_Id, Channels_Id = @Channels_Id, Company_id = @Company_id, Active = @Active, Always_available = @Always_available, ClientManager_id = @ClientManager_id, TipoContratto = @TipoContratto, ImportoRevenue = @ImportoRevenue, ImportoSpese = @ImportoSpese, SpeseForfait = @SpeseForfait, ImportoSpeseForfait = @ImportoSpeseForfait, RevenueFatturate = @RevenueFatturate, SpeseFatturate = @SpeseFatturate, Incassato = @Incassato, PianoFatturazione = @PianoFatturazione, MetodoPagamento = @MetodoPagamento, TerminiPagamento = @TerminiPagamento, CodiceCliente = @CodiceCliente, Note = @Note, ActivityOn = @ActivityOn WHERE (Projects_Id = @Projects_Id)">
            <SelectParameters>
                <asp:QueryStringParameter Name="ProjectCode" QueryStringField="ProjectCode" 
                    Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="Projects_Id" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ProjectCode" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="ProjectType_Id" Type="Int32" />
                <asp:Parameter Name="Channels_Id" Type="Int32" />
                <asp:Parameter Name="Company_id" Type="Int32" />
                <asp:Parameter Name="Active" Type="Boolean" />
                <asp:Parameter Name="Always_available" Type="Boolean" />
                <asp:Parameter Name="ClientManager_id" Type="Int32" />
                <asp:Parameter Name="TipoContratto" Type="Int32" />
                <asp:Parameter Name="ImportoRevenue" Type="Decimal" />
                <asp:Parameter Name="ImportoSpese" Type="Decimal" />
                <asp:Parameter Name="SpeseForfait" Type="Boolean" />
                <asp:Parameter Name="ImportoSpeseForfait" Type="Decimal" />
                <asp:Parameter Name="RevenueFatturate" Type="Decimal" />
                <asp:Parameter Name="SpeseFatturate" Type="Decimal" />
                <asp:Parameter Name="Incassato" Type="Decimal" />
                <asp:Parameter Name="PianoFatturazione" Type="String" />
                <asp:Parameter Name="MetodoPagamento" Type="String" />
                <asp:Parameter Name="TerminiPagamento" Type="String" />
                <asp:Parameter Name="CodiceCliente" Type="String" />
                <asp:Parameter Name="Note" Type="String" />
                <asp:Parameter Name="ActivityOn" />
                <asp:Parameter Name="Projects_Id" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ProjectCode" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="ProjectType_Id" Type="Int32" />
                <asp:Parameter Name="Channels_Id" Type="Int32" />
                <asp:Parameter Name="Company_id" Type="Int32" />
                <asp:Parameter Name="Active" Type="Boolean" />
                <asp:Parameter Name="Always_available" Type="Boolean" />
                <asp:Parameter Name="ClientManager_id" Type="Int32" />
                <asp:Parameter Name="TipoContratto" Type="Int32" />
                <asp:Parameter Name="ImportoRevenue" Type="Decimal" />
                <asp:Parameter Name="ImportoSpese" Type="Decimal" />
                <asp:Parameter Name="SpeseForfait" Type="Boolean" />
                <asp:Parameter Name="ImportoSpeseForfait" Type="Decimal" />
                <asp:Parameter Name="RevenueFatturate" Type="Decimal" />
                <asp:Parameter Name="SpeseFatturate" Type="Decimal" />
                <asp:Parameter Name="Incassato" Type="Decimal" />
                <asp:Parameter Name="PianoFatturazione" Type="String" />
                <asp:Parameter Name="MetodoPagamento" Type="String" />
                <asp:Parameter Name="TerminiPagamento" Type="String" />
                <asp:Parameter Name="CodiceCliente" Type="String" />
                <asp:Parameter Name="Note" Type="String" />
                <asp:Parameter Name="ActivityOn" />
            </InsertParameters>
        </asp:SqlDataSource>
    </form>
</body>
</html>
